import { Rect } from './rect';
import { Point } from './point';

export abstract class BaseGeometry {
    private _x: number;
    private _y: number;
    private _width: number;
    private _height: number;
    constructor(x: number, y: number, width: number, height: number) {
        this._x = x;
        this._y = y;
        this._width = width;
        this._height = height;
    }
    public get x() {
        return this._x;
    }
    public get y() {
        return this._y;
    }
    public get width() {
        return this._width;
    }
    public get height() {
        return this._width;
    }
    public get bounds(): Rect {
        return new Rect(this._x, this._y, this._width, this._height);
    }
    /**
     * 判断是否落在形状内
     * @param point 
     */
    abstract pointInThis(point: Point): boolean;
    /**
     * 计算线段与此几何图形的焦点
     * @param pStart 
     * @param pEnd 
     */
    abstract getIntersectPoints(pStart: Point, pEnd: Point): Point[];
}